package jkCore.utils;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import com.google.gson.Gson;

import jkCore.nativeNotification.NativeNotification;
import jkCore.nativeNotification.NotifyData;

public class AlarmService extends Service {
    private static String TAG = "AlarmService";

    public AlarmService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.d(TAG, "onStartCommand flags = " + flags + " startId = " + startId);

        switch (intent.getAction()) {
            case "Notify_Action":
                String json = intent.getStringExtra(AlarmTimer.Extra_Key);
                Gson gson = new Gson();
                NotifyData notifyData = gson.fromJson(json, NotifyData.class);
                NativeNotification.scheduleNotifications(notifyData.id, notifyData.period, this);

                break;
            default:
                break;
        }

        return super.onStartCommand(intent, flags, startId);
    }
}
